﻿using System;
using Framework.Common;
using Framework.Common.Attributes;
using System.Linq;
namespace Framework.Sample
{
    public class Program
    {
        static void Main(string[] args)
        {
            typeof(ITest)
                .Assembly.Print()
                .GetTypes()
                .Where(t => typeof(ITest).IsAssignableFrom(t))
                .OrderBy(i => i.Name)
                .Each(i =>
                {
                    var attrs = i.GetCustomAttributes(typeof(OrderedDescAttribute), false);
                    if (attrs != null && attrs.Length > 0)
                    {
                        Console.WriteLine(((OrderedDescAttribute)attrs[0]).Description);
                    }
                });
            int index = Console.ReadLine().StrToInt32();
            //invoke
            ITest itest = (ITest)Activator.CreateInstance(Type.GetType("Framework.Sample.Test" + index));
            itest.Run();


            Console.Read();
        }
    }

    public interface ITest
    {
        void Run();
    }

}